
package tests.laurens;

/**
 * @author Laurens Andriessen
 * @version 1.0
 */

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.SwingUtilities;

import combat.dudes.DudesFunctions;


class Testing {
	public void buildGUI() {
		JFrame f = new JFrame();
		ImageBackgroundJDesktopPane desktop = new ImageBackgroundJDesktopPane();
		// above to have image displayed on desktop, or comment out above line, uncomment next two
		// JDesktopPane desktop = new JDesktopPane();
		// desktop.setBackground(Color.BLUE);
		JInternalFrame internalFrame = new JInternalFrame("Frame", true, true, true, true);
		internalFrame.setOpaque(false);
		internalFrame.getContentPane().setBackground(new Color(0, 0, 0, 200));
		internalFrame.setPreferredSize(new Dimension(300, 300));
		internalFrame.pack();
		internalFrame.setVisible(true);
		desktop.add(internalFrame);

		f.getContentPane().add(desktop);
		f.setSize(500, 500);
		f.setLocationRelativeTo(null);
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		f.setVisible(true);
	}
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				new Testing().buildGUI();
			}
		});
	}
}


class ImageBackgroundJDesktopPane extends JDesktopPane {
	Image img;
	public ImageBackgroundJDesktopPane() {
		try {
			img = DudesFunctions.File.getImage("bg.png");
		} catch(Exception e) {}// do nothing
	}
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		if(img != null) g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
	}
}
